package net.togogo.listener;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.ContextStartedEvent;
import org.springframework.context.event.ContextStoppedEvent;

public class ApplicationEventListener implements ApplicationListener {

    @Override
    public void onApplicationEvent(ApplicationEvent event) {

        if (event instanceof ContextRefreshedEvent){
            System.out.println("ContextRefreshedEvent事件被刷新了");
        }

        if (event instanceof ContextStartedEvent){
            System.out.println("ContextStartedEvent事件开始了");
        }

        if (event instanceof ContextStoppedEvent){
            System.out.println("ContextStoppedEvent结束事件");
        }

        if (event instanceof ContextClosedEvent){
            System.out.println("ContextClosedEvent关闭事件");
        }
    }
}
